import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/13 11:57
 */

public class Solution {
    /**
     * 计算买到指定位置所需的时间
     * @param tickets 每个人想要购买的票数数组
     * @param k 目标顾客的索引位置
     * @return 返回目标顾客买票所需时间
     */
    public int timeRequiredToBuy(int[] tickets, int k) {
        Queue<Integer> queue = new LinkedList<>();
        int time = 0;
        // 将所有顾客的索引加入队列
        for (int i = 0; i < tickets.length; i++) {
            queue.offer(i);
        }

        // 当队列不为空时，继续买票过程
        while (!queue.isEmpty()) {
            int cur = queue.poll();
            tickets[cur]--;
            time++;

            // 如果当前顾客是目标顾客且票已买完，返回总耗时
            if (tickets[cur] == 0 && cur == k) {
                return time;
            }

            // 如果当前顾客还需要买票，重新加入队列尾部
            if (tickets[cur] > 0) {
                queue.offer(cur);
            }
        }

        return time;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] tickets = new int[n];
            for (int i = 0; i < tickets.length; i++) {
                tickets[i] = in.nextInt();
            }
            int k = in.nextInt();
            Solution solution = new Solution();
            System.out.println(solution.timeRequiredToBuy(tickets, k));
        }
    }
}